package com.hlhj.carview.aty

import com.hlhj.carview.BaseAty
import com.hlhj.carview.Iview.AboutUsView
import com.hlhj.carview.R
import com.hlhj.carview.bean.MyBaseBean
import com.hlhj.carview.presenter.AboutUsPresenter
import com.tencent.smtt.sdk.WebChromeClient
import com.tencent.smtt.sdk.WebSettings
import com.tencent.smtt.sdk.WebView
import com.tencent.smtt.sdk.WebViewClient
import kotlinx.android.synthetic.main.aty_web.*
import kotlinx.android.synthetic.main.lo_pubhead.*

/**
 *NeverMore
 *2020/9/10
 **/
class WebAty:BaseAty<AboutUsView,AboutUsPresenter> (), AboutUsView {


    override fun setAboutUs(myBaseBean: MyBaseBean) {
    }

    override fun initView() {

        webView.settings.setJavaScriptEnabled(true);
        webView.getSettings().setSupportZoom(true);
        webView.getSettings().setBuiltInZoomControls(true);
        webView.getSettings().setUseWideViewPort(true);
        webView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
        webView.getSettings().setLoadWithOverviewMode(true);
        webView?.webViewClient=object :WebViewClient(){
            override fun shouldOverrideUrlLoading(p0: WebView?, p1: String?): Boolean {
                p0?.loadUrl(p1)
                return true
            }
        }
        webView?.webChromeClient=object :WebChromeClient(){
            override fun onProgressChanged(p0: WebView?, p1: Int) {
                progress?.setProgress(p1)
                super.onProgressChanged(p0, p1)

            }
        }
        tvTittle.text=intent.getStringExtra("name")
        if (!intent.getBooleanExtra("isWeb",false)){
            if (intent.getStringExtra("name").equals("隐私政策")){
                webView.loadUrl("https://wx.jzxhmo.com/App/oftenUsed/toIosPrivatePolicy")
            }else{
                webView.loadDataWithBaseURL(null,intent.getStringExtra("html"), "text/html", "utf-8", null)
            }

        }else{
            webView.loadUrl(intent.getStringExtra("url"))

        }
    }

    override fun logicStart() {
    }

    override fun setListener() {
    }

    override fun getContentID(): Int {
        return R.layout.aty_web
    }

    override fun bindView(): AboutUsView {
        return this
    }

    override fun createPresenter(): AboutUsPresenter {
        return AboutUsPresenter()
    }
}